<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
        body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=ouzH2yPmscyPympLLM1Azii2HLXOyjUy"></script>
    <title>单击获取点击的经纬度</title>
    <link rel="stylesheet" href="./../../layui/css/layui.css" media="all">
    <script src="./../../layui/layui.js"></script>
    <script src="./../../js/jquery-1.8.3.min.js"></script>
    <script src="./../../js/env.js"></script>
</head>
<body>
<div id="allmap"></div>

</body>
</html>
<script type="text/javascript">
    if(layui.sessionData('user').userInfo===undefined){
        window.location.href = "../html/login.html"
    }
    layui.use(['form', 'layedit', 'laydate'], function() {

    });
    // 百度地图API功能
    var map = new BMap.Map("allmap");
    map.centerAndZoom("北京", 12);
    //单击获取点击的经纬度
    map.addEventListener("click", function (e) {
        layer.msg("经度：" + e.point.lng + "   维度：" + e.point.lat);
        parent.$("#latlng").val("经度：" + e.point.lng + "   维度：" + e.point.lat)
        parent.$("#lng").val( e.point.lng )
        parent.$("#lat").val( e.point.lat )
    });

    var top_left_control = new BMap.ScaleControl({anchor: BMAP_ANCHOR_TOP_LEFT});// 左上角，添加比例尺
    var top_left_navigation = new BMap.NavigationControl();  //左上角，添加默认缩放平移控件
    var top_right_navigation = new BMap.NavigationControl({
        anchor: BMAP_ANCHOR_TOP_RIGHT,
        type: BMAP_NAVIGATION_CONTROL_SMALL
    }); //右上角，仅包含平移和缩放按钮
    //添加控件和比例尺
    map.addControl(top_left_control);
    map.addControl(top_left_navigation);
    map.addControl(top_right_navigation);
</script>
